﻿using System;
using System.Collections;
using MvcApplication1.Utility;
using RIMS.Lib.Manager;
using RIMS.Lib.Models;

namespace MvcApplication1.Actions.EmployeeActions
{
    public class Delete : Common, IDelete
    {
//        private readonly IEmployeeManager _employeeManager;
//        public Delete(IEmployeeManager employeeManager)
//        {
//            _employeeManager = employeeManager;
//        }

        public Hashtable Execute(Guid oid)
        {
            Hashtable result = new Hashtable();
            result[Tools.IS_ERROR] = true;
            try
            {
                if (oid == Guid.Empty)
                {
                    result[Tools.MESSAGE] = "Not a valid employee";
                    return result;
                }

                Employee employee = new EmployeeManager().GetEmployee(oid);

                if (employee == null)
                {
                    result[Tools.MESSAGE] = "Employee not found";
                    return result;
                }

                if (!new EmployeeManager().Delete((employee)))
                {
                    result[Tools.MESSAGE] = "Employee not deleted";
                    return result;
                }

                result[Tools.DELETED] = true;
                result[Tools.MESSAGE] = "Delete successfully";
                result[Tools.IS_ERROR] = false;
                return result;
            }
            catch (Exception ex)
            {
                return result;
            }
        }
    }
}